home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
aix41
/
emd.z
/
emd
/
bin
/
.deinstall
next >
Wrap
Text File
|
1998-06-30
|
12KB
|
515 lines
#!/bin/sh
#
# Script: .deinstall
#
# deinstall does the following:
#
# 1) stops all Enlighten daemons
# 2) removes rc references entered by e_putrc
# 3) removes the dbenl and informix user accounts
# 4) removes the enlighten and emd directories
# 5) removes the /etc/enlighten file
#
# grep for 'Main' for the start of the script.
#
# Copyright (c) 1990-1998 Enlighten Software Solutions, Inc.
# All Rights Reserved.
#
# 1aug96 mrm
# 14jan97 mrm - incorporated AIX rc.nfs fix
# 23jan97 mrm - added OSF support
# 23jan97 mrm - moved rc references to rc3.d where applicable.
PATH=/bin:/usr/bin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH
export PATH
# OS-specific setup
case "`echo 'a\c'`" in
'a\c')
ECHO="echo -n"
NO_NL=""
;;
* )
ECHO="echo"
NO_NL="\c"
;;
esac
PSOPTS="-e"
PIDCOLUMN=1
if [ "$OS" = "SunOS" ]; then
case "$REV" in
4.1.* )
PSOPTS="-axuww"
PIDCOLUMN=2
;;
esac
fi
errorCheck () {
#
# errorCheck can be used for all commands except grep
#
if [ $? -ne 0 ] ; then
echo "$appName: Fatal: Could not deinstall Enlighten." 1>&2
exit 1
fi
}
errorCheck2 () {
#
# errorCheck can be used for grep, which returns 2 on error
#
if [ $? -eq 2 ] ; then
echo "$appName: Fatal: Could not deinstall Enlighten." 1>&2
exit 1
fi
}
should_i_continue () {
$ECHO "$appName: [y|n|exit] (default is 'y') > $NO_NL"
read response;
case "$response" in
"" | y* | Y* )
CONTINUE=yes
;;
n* | N* )
echo "$appName: Deinstallation of Enlighten will not be complete."
CONTINUE=no
;;
* )
echo "$appName: Exitting."
echo
exit 2
;;
esac
}
VerifyUserIsRoot () {
USER_ID=`id | tr "\(" "=" | cut "-d=" -f2`
if [ ! $USER_ID = 0 ] ; then
echo
echo "### $appName must be run by the 'root' superuser."
echo " Please login as root and try again."
echo
echo "Exitting. All partitions left untouched."
echo
exit 2
fi
}
VerifyScriptIsRunningFromTmpDir () {
if [ ! "$fullAppDirName" = "$ENLIGHTEN" -o ! `pwd` = "$ENLIGHTEN" ] ; then
if [ -f $ENLIGHTEN/$appName ] ; then
rm /$ENLIGHTEN/$appName
fi
cp $fullAppDirName/$appName $ENLIGHTEN/$appName
chmod 700 $ENLIGHTEN/$appName
if [ -x $ENLIGHTEN/$appName ] ; then
echo "Please cd into $ENLIGHTEN and invoke ./$appName to deinstall Enlighten."
exit 0
else
echo "$appName: Fatal: Could not copy $appName to $ENLIGHTEN."
echo "$appName: This script must be copied into $ENLIGHTEN to run."
exit 1
fi
fi
}
#
# Put the pid(s) of process(es) from $procs into $pid
#
getPid() {
# Search for:
# bin/renld -v 0
# renld -v 0
# renld
psList=`ps $PSOPTS | egrep -v "$appName|grep"`
pid=""
for i in $procs ; do
newpid=`echo "$psList" | egrep "\/$i | $i |[\/ ]$i$" | \
sed -e 's/^ *//' -e 's/ .*//'`
pid="$pid $newpid"
#echo $i is pid $newpid.
done
pid=`echo $pid`
}
#
# Kill process(es) in $procs.
#
killProcs() {
getPid $procs
if [ -n "$pid" ] ; then
if [ "$KILLOPTS" = "-9" -o "$KILLOPTS" = "-KILL" ] ; then
echo "$appName: Killing the following processes:"
else
echo "$appName: Stopping the following processes:"
fi
echo "$psList" | grep PID
for i in $pid ; do
echo "$psList" | grep $i
kill $KILLOPTS $i
done
fi
}
export procs pid psList KILLOPTS
StopENlightenProcesses () {
KILLOPTS="-9"
procs="xenln sm enl_xinstall renldc"
killProcs
if [ -x $ENLIGHTEN/bin/stop_enl_daemons ] ; then
$ENLIGHTEN/bin/stop_enl_daemons
errorCheck
elif [ -x $EMD_DIR/bin/stop_enl_daemons ] ; then
$EMD_DIR/bin/stop_enl_daemons
errorCheck
else
echo "$appName: 'stop_enl_daemons' was missing."
echo "$appName: 'rm' may fail if Enlighten processes are still active."
fi
}
cleanup_rc() {
if [ -f $RC_DIR/$RC_FILE ] ; then
echo "$appName: Remove Enlighten references from $RC_DIR/$RC_FILE?"
should_i_continue
if [ $CONTINUE = yes ] ; then
if [ "$RC_FILE" = "S92startenl" -o "$RC_FILE" = "S920enlighten" ] ; then
mv $RC_DIR/$RC_FILE /tmp/$RC_FILE.old ; errorCheck
echo "$appName: $RC_DIR/$RC_FILE was archived to /tmp/$RC_FILE.old"
elif [ "$RC_FILE" = "enlighten" ] ; then
mv $RC_DIR/$RC_FILE /tmp/$RC_FILE.old ; errorCheck
echo "$appName: $RC_DIR/$RC_FILE was archived to /tmp/$RC_FILE.old"
rm $LINK_DIR/$LINK_FILE ; errorCheck
echo "$appName: $LINK_DIR/$LINK_FILE was removed."
rm $LINK_DIR_STOP/$LINK_FILE_STOP ; errorCheck
echo "$appName: $LINK_DIR_STOP/$LINK_FILE_STOP was removed."
else
cp $RC_DIR/$RC_FILE $RC_DIR/$RC_FILE.old
errorCheck
echo "$appName: $RC_DIR/$RC_FILE was archived to $RC_DIR/$RC_FILE.old"
egrep -v "S92startenl|start_enl_daemons|start_dsmld" $RC_DIR/$RC_FILE > $RC_DIR/$RC_FILE.new
errorCheck2
mv $RC_DIR/$RC_FILE.new $RC_DIR/$RC_FILE
errorCheck
chown root $RC_DIR/$RC_FILE
errorCheck
chmod 744 $RC_DIR/$RC_FILE
errorCheck
fi
fi
fi
}
RemoveStartupScripts () {
# Remove rc references
case `uname -s` in
OSF1 )
RC_DIR=/sbin/init.d
RC_FILE=enlighten
LINK_FILE=S920enlighten
LINK_DIR=/sbin/rc3.d
LINK_FILE_STOP=K12enlighten
LINK_DIR_STOP=/sbin/rc0.d
;;
HP-UX )
case `uname -r` in
?.10.* )
RC_DIR=/sbin/init.d ; export RC_DIR
RC_FILE=enlighten ; export RC_FILE
LINK_DIR=/sbin/rc2.d ; export LINK_DIR
LINK_FILE=S920enlighten ; export LINK_FILE
LINK_FILE_STOP=K12enlighten ; export LINK_FILE_STOP
LINK_DIR_STOP=/sbin/rc0.d ; export LINK_DIR_STOP
;;
* )
RC_DIR=/etc ; export RC_DIR
RC_FILE=rc ; export RC_FILE
;;
esac
;;
AIX )
# There may be entries in rc.nfs or rc.tcpip.
RC_DIR=/etc ; export RC_DIR
RC_FILE=rc.tcpip ; export RC_FILE
cleanup_rc
RC_DIR=/etc ; export RC_DIR
RC_FILE=rc.nfs ; export RC_FILE
;;
IRIX* )
RC_DIR=/etc/init.d
RC_FILE=enlighten
LINK_FILE=S920enlighten
LINK_DIR=/etc/rc2.d
LINK_FILE_STOP=K12enlighten
LINK_DIR_STOP=/etc/rc0.d
;;
* )
if [ -d /etc/rc2.d ] ; then
RC_DIR=/etc/rc2.d ; export RC_DIR
RC_FILE=S92startenl ; export RC_FILE
cleanup_rc
RC_FILE=S920enlighten ; export RC_FILE
else
RC_DIR=/etc ; export RC_DIR
RC_FILE=rc.local ; export RC_FILE
fi
;;
esac
cleanup_rc
}
RemoveEMDUsers () {
# remove the dbenl and informix user accounts
#
# (Only remove dbenl and informix if this host has an emd_dir.)
if [ ! -z "$EMD_DIR" ] ; then
# Remove the dbenl accounts
if [ -z "`egrep '^dbenl:' /etc/passwd /etc/group`" ] ; then
echo "$appName: Error: The 'dbenl' user was missing."
else
echo "$appName: Remove the 'dbenl' user and group account?"
should_i_continue
if [ $CONTINUE = yes ] ; then
UMASK=`umask`
umask 077
for i in /etc/passwd /etc/group /etc/shadow ; do
if [ -f $i ] ; then
cp -p $i $i.old1 ; errorCheck
echo "$appName: $i was archived to $i.old1."
egrep -v "^dbenl:" $i > $i.new
errorCheck2
mv $i.new $i ; errorCheck
case "$i" in
/etc/shadow)
chown root $i ; errorCheck
chmod 400 $i ; errorCheck
;;
*)
chown root $i ; errorCheck
chmod 644 $i ; errorCheck
;;
esac
fi
done
umask $UMASK
# Remove AIX password references in /etc/security/passwd
if [ -f /etc/security/passwd ] ; then
cp -p /etc/security/passwd /etc/security/passwd.old1
errorCheck
echo "$appName: /etc/security/passwd was archived to /etc/security/passwd.old1."
awk 'BEGIN { FS = ":" } \
NF > 1 { flag = 0 } \
/dbenl/ { flag = 1 } \
{ if ( flag == 0 ) print }' /etc/security/passwd.old1 \
> /etc/security/passwd.new
errorCheck
mv /etc/security/passwd.new /etc/security/passwd ; errorCheck
chown root /etc/security/passwd ; errorCheck
chgrp security /etc/security/passwd ; errorCheck
chmod 400 /etc/security/passwd ; errorCheck
fi
fi
fi
# Remove the informix accounts
if [ -z "`egrep '^informix:' /etc/passwd /etc/group`" ] ; then
echo "$appName: Error: The 'informix' user was missing."
else
echo "$appName: Remove the 'informix' user and group account?"
should_i_continue
if [ $CONTINUE = yes ] ; then
UMASK=`umask`
umask 077
for i in /etc/passwd /etc/group /etc/shadow ; do
if [ -f $i ] ; then
cp -p $i $i.old2 ; errorCheck
echo "$appName: $i was archived to $i.old2."
egrep -v "^informix:" $i > $i.new
errorCheck2
mv $i.new $i ; errorCheck
case "$i" in
/etc/shadow)
chown root $i ; errorCheck
chmod 400 $i ; errorCheck
;;
*)
chown root $i ; errorCheck
chmod 644 $i ; errorCheck
;;
esac
fi
done
umask $UMASK
# Remove AIX password references in /etc/security/passwd
if [ -f /etc/security/passwd ] ; then
cp /etc/security/passwd /etc/security/passwd.old2
errorCheck
echo "$appName: /etc/security/passwd was archived to /etc/security/passwd.old2."
awk 'BEGIN { FS = ":" } \
NF > 1 { flag = 0 } \
/informix/ { flag = 1 } \
{ if ( flag == 0 ) print }' /etc/security/passwd.old2 \
> /etc/security/passwd.new
errorCheck
mv /etc/security/passwd.new /etc/security/passwd ; errorCheck
chown root /etc/security/passwd ; errorCheck
chgrp security /etc/security/passwd ; errorCheck
chmod 400 /etc/security/passwd ; errorCheck
fi
fi
fi
fi
}
RemoveGroupAccount () {
# remove the enldsm entry from group file
#
if [ -z "`egrep '^enldsm:' /etc/group`" ] ; then
echo "$appName: Error: The 'enldsm' group entry was missing."
else
echo "$appName: Remove the 'enldsm' group?"
should_i_continue
if [ $CONTINUE = yes ] ; then
for i in /etc/group ; do
if [ -f $i ] ; then
cp -p $i $i.old1 ; errorCheck
echo "$appName: $i was archived to $i.old1."
egrep -v "^enldsm:" $i > $i.new
errorCheck2
mv $i.new $i ; errorCheck
chown root $i ; errorCheck
chmod 644 $i ; errorCheck
fi
done
fi
fi
}
RemoveENlightenDirectories () {
# Remove the Enlighten and EMD directories
if [ ! -z "$ENLIGHTEN" -a -d "$ENLIGHTEN" ] ; then
echo "$appName: Recursively remove the Enlighten directory $ENLIGHTEN?"
should_i_continue
if [ $CONTINUE = yes ] ; then
rm -rf $ENLIGHTEN/* $ENLIGHTEN/.data
errorCheck
fi
fi
if [ ! -z "$EMD_DIR" -a -d "$EMD_DIR" ] ; then
echo "$appName: Recursively remove the EMD directory $EMD_DIR?"
should_i_continue
if [ $CONTINUE = yes ] ; then
rm -rf $EMD_DIR
errorCheck
fi
fi
if [ -f /etc/enlighten -a "$CONTINUE" = "yes" ] ; then
rm /etc/enlighten
errorCheck
echo "$appName: Removed /etc/enlighten."
fi
}
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Main Program
#
appName=`basename $0`
appDirName=`dirname $0`
fullAppDirName=`cd $appDirName ; pwd`
if [ ! -f /etc/enlighten ] ; then
echo
echo "$appName: ### The /etc/enlighten file is missing."
echo "$appName: ### Enlighten is probably not installed on this host."
echo "$appName: Exitting."
exit 0
else
ENLIGHTEN=`egrep "^enlighten=" /etc/enlighten | cut "-d=" -f2-`
EMD_DIR=`egrep "^emd_dir=" /etc/enlighten | cut "-d=" -f2-`
export ENLIGHTEN EMD_DIR
fi
VerifyUserIsRoot
VerifyScriptIsRunningFromTmpDir
$ECHO "$appName: Are you sure you want to deinstall Enlighten? [y|n|exit] $NO_NL"
read response;
case "$response" in
y* | Y* ) ;;
* )
echo "$appName: Cancelled."
exit 0
;;
esac
# Because the following are reversible, don't ask.
if [ -n "$EMD_DIR" ] ; then
if [ ! -f $EMD_DIR/FLEXlm/lmutil ] ; then
echo "$appName: Unable to find $EMD_DIR/FLEXlm/lmutil."
echo "$appName: Unable to stop license daemons."
else
echo ""
echo "$appName: Stopping license daemons."
su dbenl -c "$EMD_DIR/FLEXlm/lmutil lmdown -c $EMD_DIR/FLEXlm/license.dat -q"
echo ""
fi
fi
StopENlightenProcesses
RemoveStartupScripts
RemoveGroupAccount
RemoveEMDUsers
RemoveENlightenDirectories
echo "$appName: Finished."
echo
echo "All Enlighten files have been deinstalled except for"
echo "the .deinstall script. Please run the following commands"
echo "to complete the deinstall:"
echo "cd /"
echo "rm -r $ENLIGHTEN"
exit 0